<%--
  Created by IntelliJ IDEA.
  User: 0xdF
  Date: 2022/11/9
  Time: 11:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String errMSg = (String)session.getAttribute("error");
    StringBuffer bar = (StringBuffer)session.getAttribute("bar");
    String sucMSg = (String)session.getAttribute("success");
    if(errMSg!=null&&errMSg.contains("删除")){
        out.print("<script>alert(\""+errMSg+"\");</script>");
        session.removeAttribute("error");
    }
    if(sucMSg!=null&&sucMSg.contains("删除")){
        out.print("<script>alert(\""+sucMSg+"\");</script>");
        session.removeAttribute("success");
    }
%>
<html>
<head>
    <title>用户列表界面</title>
</head>
<body>
<jsp:include page="./head.jsp"/>
<center>
    <div style="margin: 60px">
        <c:if test="${not empty users}">
            <%--    对用户列表进行遍历--%>
            <table border="1">
                <tr style="height: 40px">
                    <th style="width: 10%">序号</th>
                    <th style="width: 20%">账号</th>
                    <th style="width: 20%">密码</th>
                    <th style="width: 20%">操作</th>
                </tr>
                <c:forEach items="${users}" var="user" varStatus="i">
                    <tr style="height: 30px">
                        <td style="width: 10%">${user.getId()}</td>
                        <td style="width: 20%">${user.getName()}</td>
                        <td style="width: 20%">${user.getPassword()}</td>
                        <td style="width: 20%">
                            <button>修改</button>
                            <button>删除</button>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </c:if>
        <c:if test="${empty users}">
            <h2 style="font-weight: bolder">用户列表为空！</h2>
        </c:if>
        <%= bar.toString()%>
    </div>
</center>

</body>
</html>
